/**
 * 
 */
package me.myachievements.web.account;

import me.myachievements.web.MyAchievementsSession;
import me.myachievements.web.accessible.LogOutPage;

import org.apache.wicket.Page;
import org.apache.wicket.PageParameters;
import org.apache.wicket.RestartResponseAtInterceptPageException;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

/**
 * @author besseym
 *
 */
public class AccountPanel extends Panel {

	/**
	 * @param id
	 */
	public AccountPanel(String id, Class<? extends Page> logoutPageClass) {
		super(id);
		
		add(new Label("fullname", new PropertyModel<String>(this, "session.account.name")));
		
		PageParameters parameters = new PageParameters(); 
		parameters.add(LogOutPage.REDIRECTPAGE_PARAM, logoutPageClass.getName()); 
		
		add(new BookmarkablePageLink("signout", LogOutPage.class, parameters) { 
			@Override public boolean isVisible() {
				return MyAchievementsSession.get().isAuthenticated();
			} 
		});
		
//		add(new Link("signin") {
//			
//			@Override public void onClick() {
//				throw new RestartResponseAtInterceptPageException( IndexPage.class);
//			}
//			
//			@Override public boolean isVisible() {
//				return !MyAchievementsSession.get().isAuthenticated();
//			} 
//		});
			
	}

}
